package tn.redmine.pages;

import org.openqa.selenium.By;

import core.Pilot;
import core.base.PageBase;

/**
 * Class provides access to web elements and actions on Index page
 */
public class IndexPage extends PageBase
{
	private static Pilot pilot = new Pilot();
	// Login form
	public static By txtLogin = By.id("username");
	public static By txtPassword = By.id("password");
	public static By btnLogin = By.xpath("//*[@type='submit']");
	public static By blockQuickSearch = By.id("quick-search");

	/**
	 * Initializes the IndexPage
	 */
	public IndexPage(Pilot p_manager)
	{
		super(p_manager);
	}

	public static void login()
	{
		pilot.driver().type(txtLogin, pilot.config().REDMINE_USERNAME);
		pilot.driver().type(txtPassword, pilot.config().REDMINE_PASSWORD);
		pilot.driver().click(btnLogin);
		pilot.driver().waitForVisibility(blockQuickSearch, "", true);
	}

	public static boolean isLoggedIn()
	{
		return pilot.driver().isElementPresent(blockQuickSearch);
	}
}